package com.cskaoyan.catmall.controller.background;

import com.cskaoyan.catmall.model.bo.AddressListBO;
import com.cskaoyan.catmall.model.bo.BaseParamBo;
import com.cskaoyan.catmall.model.bo.UserListBO;
import com.cskaoyan.catmall.model.bo.UserUpdateBO;
import com.cskaoyan.catmall.model.vo.*;
import com.cskaoyan.catmall.service.AddressService;
import com.cskaoyan.catmall.service.CollectService;
import com.cskaoyan.catmall.service.UserServiceZyy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @date: 2022-01-07-11-50
 * @author: ZYY
 * @description: 用户页面相关的接口
 */
@RestController
@RequestMapping("admin")
public class UserControllerZyy {

    @Autowired
    UserServiceZyy userService;

    @Autowired
    CollectService collectService;

    @Autowired
    AddressService addressService;

    /**
     * @author:zyy
     * @description: 根据输入的username模糊查询会员信息
     * @date:2022/01/07 18:58
     * @param param
     * @param userListBO
     * @return com.cskaoyan.catmall.model.vo.BaseRespVo
     */
    @RequestMapping("user/list")
    public BaseRespVo list(BaseParamBo param,UserListBO userListBO) {
        UserDataVO userData = userService.list(param,userListBO);
        return BaseRespVo.ok(userData);
    }

    /**
     * @author:zyy
     * @description: 根据会员id查询会员的信息
     * @date:2022/01/07 18:56
     * @param userListBO (包含用户id，用户名，用户手机号)
     * @return com.cskaoyan.catmall.model.vo.BaseRespVo
     */
    @RequestMapping("user/detail")
    public BaseRespVo detail(UserListBO userListBO){
        Integer id = userListBO.getId(); // 获得id;
        UserListVO userVO = userService.detail(id);
        return BaseRespVo.ok(userVO);
    }


    @RequestMapping(value = "user/update",method = RequestMethod.POST)
    public BaseRespVo update(@RequestBody UserUpdateBO userUpdateBO){
        int i = userService.update(userUpdateBO);
        return BaseRespVo.ok(i);
    }

    /**
     * @author:zyy
     * @description:  用户足迹
     * @date:2022/01/08 20:40
     * @return com.cskaoyan.catmall.model.vo.BaseRespVo
     */
    @RequestMapping("footprint/list")
    public BaseRespVo footPrintList(BaseParamBo params,Integer userId,Integer goodsId){
        FootPrintVO data =  userService.footPrintList(params,userId,goodsId);
        return BaseRespVo.ok(data);
    }

    /**
     * @author:zyy
     * @description: 搜索历史
     * @date:2022/01/09 15:29
     * @param params
     * @param userId
     * @param keyword
     * @return com.cskaoyan.catmall.model.vo.BaseRespVo
     */
    @RequestMapping("history/list")
    public BaseRespVo historyList(BaseParamBo params,Integer userId,String keyword){
        HistoryVO data = userService.historyList(params,userId,keyword);
        return BaseRespVo.ok(data);
    }

    /**
     * @author:zyy
     * @description: 意见反馈
     * @date:2022/01/09 15:30
     * @param params
     * @param username
     * @param id
     * @return com.cskaoyan.catmall.model.vo.BaseRespVo
     */
    @RequestMapping("feedback/list")
    public BaseRespVo feedbackList(BaseParamBo params,String  username,Integer id){
        FeedBackVO data = userService.feedbackList(params,username,id);
        return BaseRespVo.ok(data);
    }



    /**
     * @author:zyy
     * @description:  会员收藏显示
     * @date:2022/01/08 10:05
     * @param
     * @return com.cskaoyan.catmall.model.vo.BaseRespVo
     */
    // http://182.92.235.201:8083/admin/collect/list?page=1&limit=20&sort=add_time&order=desc
    @RequestMapping("collect/list")
    public BaseRespVo collectList(BaseParamBo params,
                                  Integer userId,
                                  Integer valueId){
        CollectDataVO data = collectService.list(params,userId,valueId);
        return BaseRespVo.ok(data);
    }



    /**
     * @author:zyy
     * @description:  地址显示
     * @date:2022/01/12 10:32
     * @param params
     * @param addressListBO
     * @return com.cskaoyan.catmall.model.vo.BaseRespVo
     */
    @RequestMapping("address/list")
    public BaseRespVo list(BaseParamBo params, AddressListBO addressListBO){
        AddressDataVO data = addressService.list(params,addressListBO);
        return BaseRespVo.ok(data);
    }

}